const mongoose = require('mongoose')

mongoose.connect('mongodb://localhost:27017/test', { useUnifiedTopology: true })

const Schema = mongoose.Schema

const useSchema = new Schema({
    email: {
        type: String,
        require: true
    },
    nickname: {
        type: String,
        required: true
    },
    password: {
        type: String,
        required: true
    },
    createdTime: {
        type: Date,
        default: Date.now
    },
    lastModifiedTime: {
        type: Date,
        default: Date.now
    },
    avatar: {
        type: String,
        default: 'public/img/avatar-default.png'
    },
    bio: {
        type: String,
        default: ''
    },
    gender: {
        type: Number,
        enum: [-1, 0, 1],
        default: -1
    },
    birthday: {
        type: Date,
        default: null
    },
    status: {
        type: Number,
    // 0 没有权限限制
    // 1 不可以评论
    // 2 不可以登录
        enum: [0, 1, 2],
        default: 0
    }
})

module.exports = mongoose.model('User', useSchema)